<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>China Fullfill</title>
<link href="/css/backstage.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/backstage.js"></script>
<link href="/css/blitzer/jquery-ui.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="/js/jquery-ui.js"></script>
<script>
	$(function(){
		$("#messageDialog").dialog({
			autoOpen:false,
			modal:true,
			show:"slide",
			buttons:{
				"<{$lang.ok}>":function(){
					$(this).dialog("close");
				}
			}
		});
		$("#confirmDialog").dialog({
			autoOpen:false,
			modal:true,
			show:"slide",
			buttons:{
				"<{$lang.ok}>":function(){
					receiving();
					$(this).dialog("close");
				},
				"<{$lang.cancel}>":function(){
					$(this).dialog("close");
				}
			}
		});
		$("#content").height($(document).height());
		$("#receiveDialog").dialog({
			autoOpen:false,
			modal:true,
			show:"slide",
			buttons:{
				"<{$lang.ok}>":function(){					
					receiving();
				},
				"<{$lang.cancel}>":function(){
					$(this).dialog("close");
				}
			}
		});
		
		$(".receive").click(function(){
			$(".<{$lang.sku}>").html($(".<{$lang.sku}>"+$(this).attr("itemid")).html());
			$(".title").html($(".title"+$(this).attr("itemid")).html());
			$(".category").html($(".category"+$(this).attr("itemid")).html());
			$(".qty").html($(".qty"+$(this).attr("itemid")).html());
			$(".weight").html($(".weight"+$(this).attr("itemid")).html());
			$("[name=itemId]").val($(this).attr("itemid"));
			$("[name=weight]").val("");
			$("[name=receiveQty]").val("");
			$("[name=nonLabelQty]").val("0");
			$("[name=remark]").val("");
			$("[name=isPacket][value=0]").attr("checked",true);
			$("#receiveDialog").dialog("open");
		});
	});
	function receiving(){
		var data = $("#editpform").serializeArray();
		$.ajax({
			url:"/product/returns/receive-add",
			type:"post",
			dataType:"json",
			async:false,
			data:data,
			success:function(json){
				var itemId = $("[name=itemId]").val();
				if(json.ask){
					$("#receiveQty"+itemId).html(json.item.received_qty);
					$("#weight"+itemId).html(json.item.weight);
					$("#nonLabled"+itemId).html(json.item.non_labeled_qty);
					$("#packaged"+itemId).html(json.item.packaged);
					$("#remark"+itemId).html(json.item.remark);
					$(".receive[itemid="+itemId+"]").parent().html("<img src='/images/icon/normal.gif' title='<{$lang.received}>'/>");
					$("#receiveDialog").dialog("close");
				}else{
					$("#messageDialog").html(json.message).dialog("open");
				}
			}
		});
	}
</script>
<style>
	html,body{text-align:center;border:none;}
	#content{width:900px;text-align:left;position:relative;margin-left:auto;margin-right:auto;background:white;height:100%}
	.contentTop{height:50px;line-height:50px;width:100%;text-align:center;font-size:15px;font-weight:bold;}
	.contentBottom{height:50px;line-height:50px;width:100%;text-align:center}
	.list{width:800px;max-height:28cm;border-collapse:collapse;margin-left:auto;margin-right:auto;}
	.list th,.list td{border:1px solid black;text-align:center;}
	.width1{width:80px;text-align:right;}
	.width2{width:170px;}
	.width3{width:100px;}
	.width4{width:150px;}
	.center{text-align:center}
	.action{cursor:pointer;marin:2px}
	.editTable td{padding:5px;text-align:left;}
</style>
</head>
<body>
<div id="content">
	<div class="contentTop"><{$lang.receive}><{$lang.msg}><{$lang.input}>(RMA:<{$receiving.receiving_code}>)</div>
	<table class="list">
	<tr><th><{$lang.sku}></th><th><{$lang.product}><{$lang.name}></th><th><{$lang.category}></th><th><{$lang.quantity}></th><th><{$lang.actual}><{$lang.quantity}></th><th><{$lang.standard}><{$lang.weight}></th><th><{$lang.actual}><{$lang.weight}></th><th><{$lang.no_label}><{$lang.quantity}></th><th><{$lang.package}>?</th><th><{$lang.exception}><{$lang.msg}></th><th><{$lang.operation}></th></tr>
		<{foreach from=$items item=item}>
		<tr>
		<td class="<{$lang.sku}><{$item.ri_id}>"><{$item.product.product_sku}></td>
		<td class="title<{$item.ri_id}>"><{$item.product.product_title}></td>
		<td class="category<{$item.ri_id}>"><{$item.product.category.poc_value}></td>
		<td class="qty<{$item.ri_id}>"><{$item.order_qty}></td>
		<td id="receiveQty<{$item.ri_id}>"><{if $item.status == 1}><{$item.received_qty}><{/if}></td>
		<td class="weight<{$item.ri_id}>"><{$item.product.product_weight}></td>
		<td  id="weight<{$item.ri_id}>"><{if $item.status == 1}><{$item.weight}><{/if}></td>
		<td id="nonLabled<{$item.ri_id}>"><{if $item.status == 1}><{$item.non_labeled_qty}><{/if}></td>
		<td id="packaged<{$item.ri_id}>"><{if $item.status == 1}><{$item.packaged}><{/if}></td>
		<td id="remark<{$item.ri_id}>"><{if $item.status == 1}><{$item.remark}><{/if}></td>
		<td>
			<{if $item.status == 1}>
			<img src='/images/icon/normal.gif' title='<{$lang.received}>'/>
			<{else}>
			<img src="/images/icon/edit.gif" class="receive" itemid="<{$item.ri_id}>" title="<{$lang.input}><{$lang.receive}><{$lang.data}>" style="cursor:pointer"/><{/if}>
		</td>
		</tr>
	<{/foreach}>
	</table>
	<div class="contentBottom">
		
	</div>

</div>
<div id="messageDialog" title="<{$lang.system}><{$lang.msg}>">
	
</div>
<div id="confirmDialog" title="<{$lang.system}><{$lang.msg}>">
	
</div>
<div id="receiveDialog" title="<{$lang.input}><{$lang.receive}><{$lang.msg}>">
	<form id="editpform">
	<table class="editTable">
		<tr><td><{$lang.product}><{$lang.sku}>:<input type="hidden" name="itemId" autocomplete="off"/></td><td class="<{$lang.sku}>"></td></tr>
		<tr><td><{$lang.product}><{$lang.name}>:</td><td class="title"></td></tr>
		<tr><td><{$lang.product}><{$lang.category}>:</td><td class="category"></td></tr>
		<tr><td><{$lang.standard}><{$lang.weight}>:</td><td class="weight"></td></tr>
		<tr><td><{$lang.actual}><{$lang.weight}>:</td><td><input type="text" name="weight" class="width4" autocomplete="off"/></td></tr>
		<tr><td><{$lang.quantity}>:</td><td class="qty"></td></tr>
		<tr><td><{$lang.actual}><{$lang.quantity}>:</td><td><input type="text" name="receiveQty" class="width4" autocomplete="off"/></td></tr>
		<tr><td><{$lang.result}></>:</td>
			<td>
			<select name="return_result">
				<option value="0"><{$lang.destory}></option>
				<option value="1" selected><{$lang.put_away_again}></option>
			</select>
			</td>
		</tr>
		<tr><td><{$lang.remark}>:</td><td><textarea name="remark" class="width4"></textarea></td></tr>
	</table>
	</form>
<div>
</body>
</html>